if (typeof nv == "undefined") {
    nv = {};
}
nv.Urls = {};
nv.Urls.ServerUrl = '//www.wikinvest.com';
(function () {
    var currentPartnerToken = "";
    nv.getCurrentPartnerToken = function () {
        return currentPartnerToken;
    };
    nv.Urls.ServerUrl = "http:\/\/www.wikinvest.com";
    nv.ServiceClass = "prod";
})();
nv.ChartsServer = "http://charts.wikinvest.com";
nv.Urls.IconUrl = nv.Urls.ServerUrl + "/plugin/images/wikinvestIcon_16x16.gif";
nv.Urls.APIUrl = nv.Urls.ServerUrl + "/wikinvest/api.php";
nv.Urls.CDNHost = "http://cdn.wikinvest.com";
nv.Urls.StockData = "http://stockdata.wikinvest.com/stockdata/";
nv.Urls.NewsData = "http://newsdata.sigfig.com/news/api.php";
nv.Urls.PortfolioRegisterPage = "https://www.wikinvest.com/account/portfolio/regx";
nv.Urls.TransparentPixel = "http://cdn.wikinvest.com/i/px.gif";
nv.Urls.AjaxSpinner = nv.Urls.CDNHost + "/common/resources/image/ajax-spinner.gif";
nv.Urls.LogoutApiUrl = "https://www.wikinvest.com/account/api/logout";
nv.IconUrl = nv.Urls.IconUrl;
nv.APIUrl = nv.Urls.APIUrl;
nv.CDNHost = nv.Urls.CDNHost;
if (typeof nv.eventDelegationPoint == 'undefined') {
    nv.eventDelegationPoint = document;
}
(function () {
    nv.defineClass = nv.CreateNamespace = function (namespace, constructor) {
        var created = false;
        var nsVars = namespace.split(".");
        var nsVarToDeclare = (function () {
            return this;
        })();
        var doAliasing = function (nsVarToDeclare, nsAlias, nsObj) {
            if (typeof nsVarToDeclare[nsAlias] == "undefined") {
                nsVarToDeclare[nsAlias] = nsObj;
            } else {
                for (var i in nsObj) {
                    if (nsObj.hasOwnProperty(i)) {
                        nsVarToDeclare[nsAlias][i] = nsObj[i];
                    }
                }
            }
        };
        for (var i = 0; i < nsVars.length; i++) {
            var ns = nsVars[i];
            var nsObj = nsVarToDeclare[ns];
            if (typeof nsObj == "undefined") {
                created = true;
                if (i == nsVars.length - 1 && constructor) {
                    nsObj = constructor;
                } else {
                    nsObj = {};
                }
                nsVarToDeclare[ns] = nsObj;
                if (ns === "Wikinvest") {
                    doAliasing(nsVarToDeclare, "nv", nsObj);
                } else if (ns === "Portfolio") {
                    doAliasing(nsVarToDeclare, "port", nsObj);
                } else if (nsObj !== constructor) {
                    var nsLower = ns.toLowerCase();
                    if (ns != nsLower) {
                        doAliasing(nsVarToDeclare, nsLower, nsObj);
                    }
                }
            }
            nsVarToDeclare = nsObj;
        }
        return created;
    };
    nv.defineFunction = function (namespace, fun) {
        fun._name = namespace;
        return nv.defineClass(namespace, fun);
    };
    nv.defineFunctions = function (namespace, funs) {
        return nv.defineClass(namespace, funs);
    };
    nv.defineEnum = function (arg1, arg2) {
        var constants = arg1;
        if (typeof arg2 != "undefined") constants = arg2;
        var obj = {};
        for (var i = 0; i < constants.length; i++) {
            obj[constants[i]] = i;
        }
        if (typeof arg2 == "undefined") return obj;
        return nv.defineClass(arg1, obj);
    };
    nv.defineSingleton = function (namespace, functionOrObject) {
        if (typeof functionOrObject === 'function') {
            var obj = {};
            functionOrObject.call(obj, obj);
            functionOrObject = obj;
        } else if (typeof functionOrObject !== 'object') {
            throw "Trying to define " + namespace + " as singleton, but passed in value is not an object.";
        }
        return nv.defineClass(namespace, functionOrObject);
    };
    var NO_BASE_CLASS = {};
    nv.defineAwesomeClass = function (fullyQualifiedClassName, userDefinedConstructor, typeConstructor) {
        return nv.extendClass(fullyQualifiedClassName, NO_BASE_CLASS, userDefinedConstructor, typeConstructor);
    };
    nv.defineAnonymousClass = function (userDefinedConstructor, typeConstructor) {
        return nv.defineAwesomeClass(null, userDefinedConstructor, typeConstructor);
    };
    nv.extendClass = function (fullyQualifiedClassName, parentClass, userDefinedConstructor, typeConstructor) {
        var fullyQualifiedClassNameStr = fullyQualifiedClassName;
        if (!fullyQualifiedClassName) {
            fullyQualifiedClassNameStr = "(anonymous class)";
        }
        if (!parentClass) {
            throw "Invalid parentClass specified while defining " + fullyQualifiedClassNameStr;
        }
        var resolvedParentClass = null;
        if (typeof parentClass != "string") {
            resolvedParentClass = parentClass;
        }
        var internallyUsedConstructor = function ($this, $protected) {
            if (parentClass != NO_BASE_CLASS) {
                if (resolvedParentClass == null) {
                    var parts = parentClass.split(".");
                    resolvedParentClass = window;
                    for (var i in parts) {
                        if (parts.hasOwnProperty(i)) {
                            resolvedParentClass = resolvedParentClass[parts[i]];
                            if (typeof resolvedParentClass == "undefined") {
                                throw "Unable to resolve parent class '" + parentClass + "', while constructing '" +
                                    fullyQualifiedClassNameStr + "'";
                            }
                        }
                    }
                }
                if (!resolvedParentClass || typeof resolvedParentClass.__originalConstructor !== "function") {
                    throw "Invalid parentClass specified while defining " + fullyQualifiedClassNameStr;
                }
                resolvedParentClass.__originalConstructor.call(this, $this, $protected);
                var $parent = {
                    $protected: {}
                };
                copyFunctions(this, $parent);
                copyFunctions($protected, $parent.$protected);
                userDefinedConstructor.call(this, $this, $protected, $parent);
            } else {
                userDefinedConstructor.call(this, $this, $protected);
                if (typeof this.__construct === 'undefined') {
                    if (typeof this.__constructor === 'function') {
                        nv.log("************************ are you sure you meant __constructor and not __construct in " + fullyQualifiedClassNameStr + "?");
                    }
                    this.__construct = function () {};
                }
            }
        };
        var constructorWrapper = function () {
            var $protected = {};
            internallyUsedConstructor.call(this, this, $protected);
            this.__construct.apply(this, arguments);
        };
        constructorWrapper.__originalConstructor = internallyUsedConstructor;
        if (fullyQualifiedClassName) {
            nv.defineClass(fullyQualifiedClassName, constructorWrapper);
        }
        if (typeof typeConstructor == 'function') {
            typeConstructor.call(constructorWrapper, constructorWrapper);
        } else if (typeof typeConstructor != "undefined" && typeConstructor !== null) {
            throw "Invalid argument for type constructor for " + fullyQualifiedClassNameStr;
        }
        return constructorWrapper;
    };
    nv.extendToAnonymousClass = function (parentClass, userDefinedConstructor, typeConstructor) {
        return nv.extendClass(null, parentClass, userDefinedConstructor, typeConstructor);
    };
    var copyFunctions = function (from, to) {
        for (var i in from) {
            if (from.hasOwnProperty(i) && typeof from[i] == "function") {
                to[i] = from[i];
            }
        }
    };
    nv.combine = function () {
        var options, name, src, copy, target = arguments[0] || {}, i = 1,
            length = arguments.length;
        for (; i < length; i++) {
            if ((options = arguments[i]) != null) {
                for (name in options) {
                    src = target[name];
                    copy = options[name];
                    if (target === copy) {
                        continue;
                    }
                    target[name] = copy;
                }
            }
        }
        return target;
    };
})();
nv.deprecated = function (fullyQualifiedDeprecatedFunctionName, newFn) {
    var deprecatedLogged = {};
    nv.defineClass(fullyQualifiedDeprecatedFunctionName, function () {
        if (typeof deprecatedLogged[fullyQualifiedDeprecatedFunctionName] == "undefined") {
            nv.trace("***DEPRECATED*** " + fullyQualifiedDeprecatedFunctionName + " is deprecated, so stop using it");
            deprecatedLogged[fullyQualifiedDeprecatedFunctionName] = true;
            if (/\bbreak\-on\-deprecated\b/.test(window.location.hash)) {
                debugger;
            }
        }
        return newFn.apply(null, arguments);
    });
};
nv.mixin = function (target, fromConstructor) {
    if (typeof target == "object" && target.constructor != Object && typeof fromConstructor == "function") {
        fromConstructor.apply(target, Array.prototype.slice.call(arguments, 2));
    } else {
        nv.error("Invalid args given to nv.mixin");
    }
};
nv.importNamespace = function (namespace) {
    var result = window;
    var pieces = namespace.split(".");
    for (var i = 0; i < pieces.length; i++) {
        var piece = pieces[i];
        var objectForPiece = result[piece];
        if (typeof objectForPiece === "object") {
            result = objectForPiece;
        } else {
            throw "Trying to import " + namespace + ", but encountered a non-object at " + piece;
        }
    }
    return result;
};
nv.NamespaceExists = function (namespace) {
    if (!namespace) {
        return false;
    }
    var nsVars = namespace.split(".");
    var nsVarToCheck = window;
    for (var i = 0; i < nsVars.length; i++) {
        if (typeof nsVarToCheck[nsVars[i]] == "undefined") {
            return false;
        }
        nsVarToCheck = nsVarToCheck[nsVars[i]];
    }
    return true;
};
nv.Debug = (nv.ServiceClass == "dev" ? true : false);
if (document.location.search && document.location.search.match(/nvDebug/)) {
    nv.Debug = true;
}
(function () {
    var shouldLogForLabel = function (label) {
        try {
            if (label) {
                label = label.replace(new RegExp("[.*+?|()\\[\\]{}\\\\]", "g"), "\\$&");
            }
            return !label || new RegExp("(#|,)" + label + "(,|$)").test(window.location.hash);
        } catch (e) {
            return false;
        }
    };
    var getMessageWithLabel = function (msg, label) {
        if (label) {
            msg = "[" + label + "] " + msg;
        }
        return msg;
    };
    nv.error = function (msg, label) {
        if (nv.Debug || label) {
            if (!shouldLogForLabel(label)) {
                return;
            }
            msg = getMessageWithLabel(msg, label);
            if (typeof (console) != 'undefined' && typeof (console.error) != 'undefined') {
                console.error(msg);
            } else {
                if (nv.ServiceClass == "dev") {
                    throw new Error(msg);
                }
            }
        }
    };
    nv.log = function (msg, label) {
        if (nv.Debug || label) {
            if (!shouldLogForLabel(label)) {
                return;
            }
            msg = getMessageWithLabel(msg, label);
            if (typeof (console) != 'undefined' && typeof (console.log) != 'undefined') {
                console.log(msg);
            }
        }
    };
    nv.trace = function (message) {
        nv.log(message + "\n" + "See stack trace below:");
        if (typeof console != "undefined" && typeof console.trace != "undefined") {
            console.trace();
        } else {
            nv.log("Sorry, console.trace() is not available on this browser");
        }
    };
    nv.LogDir = function (msg, label) {
        if (nv.Debug || label) {
            if (!shouldLogForLabel(label)) {
                return;
            }
            msg = getMessageWithLabel(msg, label);
            if (typeof (console) != 'undefined' && typeof (console.dir) != 'undefined') {
                console.dir(msg);
            }
        }
    };
    var canvasElement = document.createElement("canvas");
    if ( !! canvasElement.getContext && !! canvasElement.getContext("2d")) {
        nv.CANVAS = true;
    }
    if ( !! document.createElementNS && !! document.createElementNS("http://www.w3.org/2000/svg", "svg").createSVGRect) {
        nv.SVG = true && !(/Firefox\/[0123]\./.test(navigator.userAgent));
    }
    var msie = /MSIE\s*(\d+)/.exec(navigator.userAgent);
    nv.DATA_URI = msie ? msie[1] > 7 : true;
    nv.EXPENSIVE_FEATURES = nv.DATA_URI;
})();
nv.Var = new function () {};